<%--
  Created by IntelliJ IDEA.
  User: ZhuChunXiao
  Date: 2017/5/18
  Time: 17:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<div id="page-content">
  <div class="row">

    <div class="col-lg-12">
      <div class="panel">
        <div class="panel-heading">
          <h3 class="panel-title">人事信息 - 所有员工</h3>
        </div>
        <div class="panel-body">
          <div class="form-inline">
            <div class="row">
              <div class="col-sm-12 table-toolbar-left">
                <btn id="btn_add_personnelinfo" class="btn btn-primary btn-sm">
                  <i class="ti-plus"> </i> 新建人事信息表
                </btn>
              </div>
            </div>
          </div>

          <div class="table-responsive">
            <table id="personnelinfo_out_table"></table>
            <div id="personnelinfo_out_page"></div>
          </div>
        </div>
      </div>
    </div>

  </div>
</div>

<script>

  $(function(){

    init_grid_personnelinfo();

  });

  function init_grid_personnelinfo() {

    __init_jqgrid('personnelinfo_out_table', 'personnelinfo_out_page',
            '<%=path%>/activiti/personnelinfo/list',
            ['用工性质', '姓名', '年龄', '性别', '所属部门', '岗位', '移动电话', '操作', 'id'],
            [
              {name: 'nature', index: 'nature', width: 40, sortable: false, search: false, formatter: useTypeFormat},
              {name: 'name', index: 'name', sortable: false, stype: 'text', searchoptions: {sopt: ['cn']}},
              {name: 'age', index: 'age', width: 40, sortable: false, search: false},
              {name: 'sex', index: 'sex', width: 40, sortable: false, search: true, searchoptions: {sopt: ['cn']}},
              {name: 'department', index: 'department', width: 100, sortable: false, search: true, searchoptions: {sopt: ['cn']}},
              {name: 'post', index: 'post', width: 100, sortable: false, search: true, searchoptions: {sopt: ['cn']}},
              {name: 'phone', index: 'phone', width: 100, sortable: false, search: true, searchoptions: {sopt: ['cn']}},
//              {name: 'txtStatus', index: 'txtStatus', width: 40, sortable: false, search: false},
              {name: 'act', index: 'act', width: 250, fixed: true, sortable: false, search: false, formatter: actFormat},
              {name: 'id', index: 'id', width: 100, key: true, hidden: true, hidedlg: true}
            ],
            true,
            {
              postData: {catalog: 0x05}
            }
    );

  }

  function useTypeFormat(cellvalue, options, rowObject){
    if(rowObject.nature == 1){
      cellvalue = "正式员工";
    } else if(rowObject.nature == 2){
      cellvalue = "试用员工";
    }else{
      cellvalue = "暂无";
    }
    return cellvalue;
  }

  function actFormat(cellvalue, options, rowObject){
    var id = rowObject.id;
    cellvalue = '<button class="btn btn-white btn-sm" data-original-title="查看" onclick="fn_personnelinfo_read(\'' + id + '\');"><i class="fa fa-eye"> </i> 查看</button> ';
    return cellvalue;
  }

  function fn_personnelinfo_read(id) {
    loadURL('<%=path%>/activiti/personnelinfo/read/'+id, $('#page-content'));
  }

  $("#btn_add_personnelinfo").click(function(){
    loadURL('<%=path%>/activiti/personnelinfo/create', $('#page-content'));
  });

</script>